﻿Option Infer On
Option Strict Off

Imports bbAppFxWebAPI = Blackbaud.AppFx.WebAPI



Namespace AddForms

    Namespace [Revenue]





        ''' <summary>
        ''' Provides WebApi access to the "Revenue Add Data Form Custom" catalog feature.  Revenue Add Form - Custom
        ''' </summary>
        <System.CodeDom.Compiler.GeneratedCodeAttribute("BBMetalWeb", "2011.8.2.0")> _
        Public NotInheritable Class [RevenueAddDataFormCustom]

            Private Sub New()
            End Sub

            Private Shared ReadOnly _specId As Guid = New Guid("be72654a-510e-4746-a8b2-1980c08b5563")

            ''' <summary>
            ''' The Spec ID value for the "Revenue Add Data Form Custom" AddForm
            ''' </summary>
            Public Shared ReadOnly Property SpecId() As Guid
                Get
                    Return _specId
                End Get
            End Property

            Public Shared Function CreateLoadRequest(ByVal provider As bbAppFxWebAPI.AppFxWebServiceProvider) As bbAppFxWebAPI.ServiceProxy.DataFormLoadRequest
                Return Blackbaud.AppFx.WebAPI.DataFormServices.CreateDataFormLoadRequest(provider, _specId)
            End Function

            ''' <summary>
            ''' Returns an instance of RevenueAddDataFormCustomData with default data form fields populated.
            ''' </summary>
            ''' <returns>An instance of RevenueAddDataFormCustomData with the form field properties that have defaults populated with those default values.</returns>
            ''' <remarks>This function will make a web request to the AppFx WebService DataFormLoad method to obtain the default data form field values.</remarks>
            Public Shared Function LoadData(ByVal provider As bbAppFxWebAPI.AppFxWebServiceProvider) As RevenueAddDataFormCustomData



                Dim request = CreateLoadRequest(provider)





                Return LoadData(provider, request)

            End Function

            ''' <summary>
            ''' Returns an instance of RevenueAddDataFormCustomData with default data form fields populated.
            ''' </summary>
            ''' <returns>An instance of RevenueAddDataFormCustomData with the form field properties that have defaults populated with those default values.</returns>
            ''' <remarks>This function will make a web request to the AppFx WebService DataFormLoad method to obtain the default data form field values.</remarks>
            Public Shared Function LoadData(ByVal provider As bbAppFxWebAPI.AppFxWebServiceProvider, ByVal request As bbAppFxWebAPI.ServiceProxy.DataFormLoadRequest) As RevenueAddDataFormCustomData
                Return bbAppFxWebAPI.DataFormServices.GetFormData(Of RevenueAddDataFormCustomData)(provider, request)
            End Function

        End Class

#Region "Data Class"

        ''' <summary>
        ''' Represents the data form field values in the "Revenue Add Data Form Custom" data form.
        ''' </summary>
        <System.CodeDom.Compiler.GeneratedCodeAttribute("BBMetalWeb", "2011.8.2.0")> _
        Public NotInheritable Class RevenueAddDataFormCustomData
            Inherits bbAppFxWebAPI.AddFormData

#Region "Constructors"

            Public Sub New()
                MyBase.New()
            End Sub

            Friend Sub New(ByVal reply As bbAppFxWebAPI.ServiceProxy.DataFormLoadReply, ByVal request As bbAppFxWebAPI.ServiceProxy.DataFormLoadRequest)
                MyBase.New()
                If (reply IsNot Nothing) AndAlso (reply.DataFormItem IsNot Nothing) Then
                    Me.SetValues(reply.DataFormItem)
                End If
            End Sub

            Public Sub New(ByVal dfi As Blackbaud.AppFx.XmlTypes.DataForms.DataFormItem)
                MyBase.New()
                Me.SetValues(dfi)
            End Sub

            Public Sub New(ByVal dataFormItemXml As String)
                MyBase.New()
                Me.SetValuesFromDataFormItem(dataFormItemXml)
            End Sub

#End Region

#Region "Form Field Properties"

            Private [_ConstituentID] As Nullable(Of System.Guid)
            ''' <summary>
            ''' ConstituentID
            ''' </summary>
            Public Property [ConstituentID] As Nullable(Of System.Guid)
                Get
                    Return Me.[_ConstituentID]
                End Get
                Set(ByVal value As Nullable(Of System.Guid))
                    Me.[_ConstituentID] = value
                End Set
            End Property

            Private [_RevenueDate] As Nullable(Of Date)
            ''' <summary>
            ''' RevenueDate
            ''' </summary>
            Public Property [RevenueDate] As Nullable(Of Date)
                Get
                    Return Me.[_RevenueDate]
                End Get
                Set(ByVal value As Nullable(Of Date))
                    Me.[_RevenueDate] = value
                End Set
            End Property

            Private [_PostDate] As Nullable(Of Date)
            ''' <summary>
            ''' PostDate
            ''' </summary>
            Public Property [PostDate] As Nullable(Of Date)
                Get
                    Return Me.[_PostDate]
                End Get
                Set(ByVal value As Nullable(Of Date))
                    Me.[_PostDate] = value
                End Set
            End Property

            Private [_Amount] As Nullable(Of Decimal) = "0.00"
            ''' <summary>
            ''' Amount
            ''' </summary>
            Public Property [Amount] As Nullable(Of Decimal)
                Get
                    Return Me.[_Amount]
                End Get
                Set(ByVal value As Nullable(Of Decimal))
                    Me.[_Amount] = value
                End Set
            End Property

            Private [_Description] As String
            ''' <summary>
            ''' Description
            ''' </summary>
            Public Property [Description] As String
                Get
                    Return Me.[_Description]
                End Get
                Set(ByVal value As String)
                    Me.[_Description] = value
                End Set
            End Property

            Private [_LookupID] As String
            ''' <summary>
            ''' LookupID
            ''' </summary>
            Public Property [LookupID] As String
                Get
                    Return Me.[_LookupID]
                End Get
                Set(ByVal value As String)
                    Me.[_LookupID] = value
                End Set
            End Property

            Private [_Designation] As String
            ''' <summary>
            ''' Designation
            ''' </summary>
            Public Property [Designation] As String
                Get
                    Return Me.[_Designation]
                End Get
                Set(ByVal value As String)
                    Me.[_Designation] = value
                End Set
            End Property

            Private [_SubDesignation] As String
            ''' <summary>
            ''' SubDesignation
            ''' </summary>
            Public Property [SubDesignation] As String
                Get
                    Return Me.[_SubDesignation]
                End Get
                Set(ByVal value As String)
                    Me.[_SubDesignation] = value
                End Set
            End Property

            Private [_ReceiptDate] As Nullable(Of Date)
            ''' <summary>
            ''' ReceiptDate
            ''' </summary>
            Public Property [ReceiptDate] As Nullable(Of Date)
                Get
                    Return Me.[_ReceiptDate]
                End Get
                Set(ByVal value As Nullable(Of Date))
                    Me.[_ReceiptDate] = value
                End Set
            End Property

            Private [_PaymentMethod] As String
            ''' <summary>
            ''' PaymentMethod
            ''' </summary>
            Public Property [PaymentMethod] As String
                Get
                    Return Me.[_PaymentMethod]
                End Get
                Set(ByVal value As String)
                    Me.[_PaymentMethod] = value
                End Set
            End Property

            Private [_PledgeId] As String
            ''' <summary>
            ''' PledgeId
            ''' </summary>
            Public Property [PledgeId] As String
                Get
                    Return Me.[_PledgeId]
                End Get
                Set(ByVal value As String)
                    Me.[_PledgeId] = value
                End Set
            End Property



#End Region

            Public Overrides ReadOnly Property DataFormInstanceID() As System.Guid
                Get
                    Return AddForms.[Revenue].RevenueAddDataFormCustom.SpecId
                End Get
            End Property

            Public Overrides Function ToDataFormItem() As Blackbaud.AppFx.XmlTypes.DataForms.DataFormItem
                Return Me.BuildDataFormItemForSave()
            End Function

            Friend Sub SetValues(ByVal dfi As Blackbaud.AppFx.XmlTypes.DataForms.DataFormItem)

                If dfi Is Nothing Then Exit Sub


                Dim value As Object = Nothing
                Dim dfiFieldValue As Blackbaud.AppFx.XmlTypes.DataForms.DataFormFieldValue = Nothing
                Dim stringFieldValue As String = Nothing

                Dim guidFieldValue As System.Guid
                Dim dateFieldValue As Date?
                guidFieldValue = System.Guid.Empty
                If dfi.TryGetValueForPropertyAssignment("ConstituentID", guidFieldValue) Then
                    Me.[ConstituentID] = guidFieldValue
                End If

                If dfi.TryGetValueForPropertyAssignment("RevenueDate", dateFieldValue) Then
                    Me.[RevenueDate] = dateFieldValue
                End If

                If dfi.TryGetValueForPropertyAssignment("PostDate", dateFieldValue) Then
                    Me.[PostDate] = dateFieldValue
                End If

                value = Nothing
                dfiFieldValue = Nothing
                If dfi.TryGetValue("Amount", dfiFieldValue) Then
                    If dfiFieldValue IsNot Nothing Then
                        value = dfiFieldValue.Value
                        If (value IsNot Nothing) AndAlso (value IsNot System.DBNull.Value) Then
                            If TypeOf value Is String Then
                                Me.[Amount] = Blackbaud.AppFx.DataListUtility.DataListStringValueToDec(value)

                            Else
                                Me.[Amount] = value
                            End If
                        End If

                    End If

                End If

                stringFieldValue = Nothing
                If dfi.TryGetValueForPropertyAssignment("Description", stringFieldValue) Then
                    Me.[Description] = stringFieldValue
                End If

                stringFieldValue = Nothing
                If dfi.TryGetValueForPropertyAssignment("LookupID", stringFieldValue) Then
                    Me.[LookupID] = stringFieldValue
                End If

                stringFieldValue = Nothing
                If dfi.TryGetValueForPropertyAssignment("Designation", stringFieldValue) Then
                    Me.[Designation] = stringFieldValue
                End If

                stringFieldValue = Nothing
                If dfi.TryGetValueForPropertyAssignment("SubDesignation", stringFieldValue) Then
                    Me.[SubDesignation] = stringFieldValue
                End If

                If dfi.TryGetValueForPropertyAssignment("ReceiptDate", dateFieldValue) Then
                    Me.[ReceiptDate] = dateFieldValue
                End If

                stringFieldValue = Nothing
                If dfi.TryGetValueForPropertyAssignment("PaymentMethod", stringFieldValue) Then
                    Me.[PaymentMethod] = stringFieldValue
                End If

                stringFieldValue = Nothing
                If dfi.TryGetValueForPropertyAssignment("PledgeId", stringFieldValue) Then
                    Me.[PledgeId] = stringFieldValue
                End If



            End Sub

            Private Function BuildDataFormItemForSave() As Blackbaud.AppFx.XmlTypes.DataForms.DataFormItem

                Dim dfi As New Blackbaud.AppFx.XmlTypes.DataForms.DataFormItem

                Dim value As Object = Nothing
                value = Me.[ConstituentID]
                dfi.SetValueIfNotNull("ConstituentID", value)
                value = Me.[RevenueDate]
                dfi.SetValueIfNotNull("RevenueDate", value)
                value = Me.[PostDate]
                dfi.SetValueIfNotNull("PostDate", value)
                value = Me.[Amount]
                dfi.SetValueIfNotNull("Amount", value)
                value = Me.[Description]
                dfi.SetValueIfNotNull("Description", value)
                value = Me.[LookupID]
                dfi.SetValueIfNotNull("LookupID", value)
                value = Me.[Designation]
                dfi.SetValueIfNotNull("Designation", value)
                value = Me.[SubDesignation]
                dfi.SetValueIfNotNull("SubDesignation", value)
                value = Me.[ReceiptDate]
                dfi.SetValueIfNotNull("ReceiptDate", value)
                value = Me.[PaymentMethod]
                dfi.SetValueIfNotNull("PaymentMethod", value)
                value = Me.[PledgeId]
                dfi.SetValueIfNotNull("PledgeId", value)


                Return dfi

            End Function

            Public Overrides Sub SetValuesFromDataFormItem(ByVal dataFormItem As Blackbaud.AppFx.XmlTypes.DataForms.DataFormItem)
                Me.SetValues(dataFormItem)
            End Sub



        End Class

#End Region

    End Namespace

End Namespace

